<?xml version="1.0" encoding="utf-8" ?> 
<taskrunner name="attach.databases" version="1.0" date="2008-04-19" maxthreads="1">

	<!-- attaches databases to sql server express. -->
	
	<includes>
		<file name="vida.install.settings.xml" />
	</includes> 


	<parameters>
		<parameter name="servicerepository.database.name" value="INPUT#"/>
	</parameters>

	<tasks>

    
    <task name="start.sqlexpress.service" condition="¤{sqlserver.installed}=true" typename="@WindowsServiceCommand">
      <description>
        Starts Sql Express instance if it's already installed.
      </description>
      <errormessage>
        Could not start Sql Server Express Service
      </errormessage>
      <dependencies list="install.sqlexpress,check.installed.version"/>
      <parameters>
        <parameter name="server.name" value=""/>
        <parameter name="service.name" value="MSSQL$${sqlserver.instance.name}"/>
        <parameter name="command" value="start"/>
      </parameters>
    </task>

    <task name="localdatabase" condition="¤{KeepLocalDb}=true" typename="@WriteInformation">
      <dependencies list="start.sqlexpress.service"/>
			<description>
				
			</description>
			<parameters>
				<parameter name="message" value="AccessServer and DiagSwdlSession will NOT be replaced!"/>
			</parameters>
		</task>
    
    
	
		<task name="attach.basedata" typename="@SqlServerManagement.AttachDatabase" retry="3">
      <dependencies list="start.sqlexpress.service"/>
			<description>
				Attaches database basedata.
			</description>
      <errormessage>
        Could not attach database ${db.basedata.name}.
      </errormessage>
			
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.basedata.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.basedata.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.basedata.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
        <parameter name="DatabaseOptions.AutoClose" value="false"/>
        <parameter name="DatabaseOptions.ReadOnly" value="false"/>
			</parameters>
		</task>
    
    
		
		<task name="attach.diagswdlrepository" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches database diagswdlrepository.
			</description>
      <errormessage>
        Could not attach database ${db.diagswdlrepository.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>			
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.diagswdlrepository.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.diagswdlrepository.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.diagswdlrepository.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
		
		<task name="attach.epc" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches database EPC.
			</description>
      <errormessage>
        Could not attach database ${db.epc.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.epc.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.epc.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.epc.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
		
		<task name="attach.servicerepository" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches servicerepository database.
			</description>
      <errormessage>
        Could not attach database ${db.servicerepository.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.servicerepository.name}"/>
				<parameter name="datafile" value="${target.db.dir}\servicerep_${vida.language}.mdf"/>
				<parameter name="logfile" value="${target.db.dir}\servicerep_${vida.language}.ldf"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
		
		<task name="attach.imagerepository" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches new AccessServer database. If this database is already attached then it will not be replaced.
			</description>
      <errormessage>
        Could not attach database ${db.imagerepository.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.imagerepository.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.imagerepository.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.imagerepository.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
		
		<task name="attach.carcomrt" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches new CarComRT database. 
			</description>
      <errormessage>
        Could not attach database ${db.carcomrt.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.carcomrt.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.carcomrt.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.carcomrt.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>

    <task name="attach.dicetiming" typename="@SqlServerManagement.AttachDatabase" retry="3">
      <description>
        Attaches dicetiming database.
        This task will not be run if current installed version equals to ${previous.release} or ${release}
      </description>
      <errormessage>
        Could not attach database ${db.dicetiming.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="name" value="${db.dicetiming.name}"/>
        <parameter name="datafile" value="${target.db.dir}\${db.dicetiming.data.filename}"/>
        <parameter name="logfile" value="${target.db.dir}\${db.dicetiming.log.filename}"/>
        <parameter name="detachexisting" value="true"/>
      </parameters>
    </task>
		
		
		<task name="attach.accessserver" condition="¤{KeepLocalDb}!=true" typename="@SqlServerManagement.AttachDatabase" retry="3">
			<description>
				Attaches new AccessServer database. 
				This task will not be run if current installed version equals to ${previous.release} or ${release}
			</description>
      <errormessage>
        Could not attach database ${db.accessserver.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.accessserver.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.accessserver.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.accessserver.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
    
    
		
		<task name="attach.diagswdlsession" condition="¤{KeepLocalDb}!=true" typename="@SqlServerManagement.AttachDatabase"  retry="3">
			<description>
				Attaches new DiagSwdlSession database. 
				This task will not be run if current installed version equals to ${previous.release} or ${release}
			</description>
      <errormessage>
        Could not attach database ${db.diagswdlsession.name}.
      </errormessage>
      <dependencies list="start.sqlexpress.service"/>
			<parameters>
				<parameter name="server" value="${sqlserver.local.server}"/>
				<parameter name="userid" value="${sqlserver.local.userid}"/>
				<parameter name="password" value="${sqlserver.local.password}"/>
				<parameter name="name" value="${db.diagswdlsession.name}"/>
				<parameter name="datafile" value="${target.db.dir}\${db.diagswdlsession.data.filename}"/>
				<parameter name="logfile" value="${target.db.dir}\${db.diagswdlsession.log.filename}"/>
				<parameter name="detachexisting" value="true"/>
			</parameters>
		</task>
    
    
    
    
	</tasks>
</taskrunner>
